#include<stdio.h>

float getAvg(int arr[], int size){
    int sum = 0;
    for (int i = 0; i < size; i++){
        sum += arr[i];
    }

    printf("%d, %d,\n", sum, size);
    return (float)sum/size;//必须强转为float才会有小数，否则会只保留整数
}

int main(){
    //n++会在使用掉n后加1，++n会在使用n之前加1.
    int i = 10;
    int n = 10;

    printf("%d, %d\n", ++i, n++);
    printf("%d, %d\n", i, n);

    //数组是固定长度存放相同任意类型的顺序集合
    //decleration：
    int numbers[3];

    //init
    int nums[3] = {1, 2, 3};

    //二维数组：
    int x[3][4];//三行四列

    int y[3][4] = {
        {1, 2, 3, 4},
        {5, 6, 7, 8},
        {11, 22, 33, 44}
    }; 

    //函数传入数组
    int list[] = {1, 2, 4, 0};
    int size  = 4;
    float avg = getAvg(list, size);
    printf("%.4f", avg);
}

